package com.sanpu.kxe.business.main.adapter;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.sanpu.kxe.business.main.bean.NewsColumnsOutput;
import com.sanpu.kxe.business.main.fragment.NewsColumnFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Description：新闻
 * Created by 薛勇军 on 2018/8/29.
 */

public class NewsPagerAdapter extends FragmentPagerAdapter {

    ArrayList<NewsColumnFragment> fragments = new ArrayList<>();

    public NewsPagerAdapter(FragmentManager fm, List<NewsColumnsOutput> columnsOutputs) {
        super(fm);
        if (columnsOutputs != null && columnsOutputs.size() > 0) {
            for (NewsColumnsOutput columnsOutput : columnsOutputs) {
                fragments.add(NewsColumnFragment.getInstance(columnsOutput.getColumnType()));
            }
        }
    }

    @Override
    public NewsColumnFragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return "";
    }
}
